<template>
  <div class="caption-title">
    <i class="fl"><img :src=left  alt=""></i>
    <span class="biaoti fl">数字巡护管理平台</span>
    <i class="fr"><img :src=right  alt=""></i>
  </div>

  <div class="info">
    <div class="date">
      {{date.year}}年{{date.month}}月{{date.day}}日 &nbsp;&nbsp;{{date.weekDay}}&nbsp;&nbsp;
      {{ time }}
    </div>
    <div class="user-manage">
      <div class="options">
        <div class="word" @click="toUser">
          <div class="container">
            <el-icon><User /></el-icon>
          </div>
          用户中心
        </div>
        <div class="back" v-if="show" @click="backHome">
          <el-icon
              style=""
          >
            <ArrowLeftBold />
          </el-icon>
          返回
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import left from "@/assets/images/title/title-left.png"
import right from "@/assets/images/title/title-right.png"
import {User, ArrowLeftBold} from "@element-plus/icons-vue"
import {onMounted, reactive, ref, watch} from "vue"
import {getCurrentDateInfo, getCurrentTime} from "@/utils/common/common"
import {useRouter} from "vue-router"

let date = reactive({})
let time = ref('')

date = getCurrentDateInfo()
setInterval(()=>{
  time.value = getCurrentTime()
},1000)

const router = useRouter()
const position = ref()
const show = ref(false)

onMounted(()=>{
  position.value = router.currentRoute.value.path
  console.log(router.currentRoute.value.name)
})

const toUser = () => {
  if (router.currentRoute.value.name === 'user')return
  router.push('/user/info')
}

const backHome = () => {
  router.push('/homepage')
}

watch(() => router.currentRoute.value.name,(newRouterName)=>{
  if (newRouterName === 'info' || newRouterName === 'manage' || newRouterName === 'mission'){
    show.value = true
  } else {
    show.value = false
  }
})
</script>

<style scoped lang="less">
.caption-title{
  font-size:22px;
  font-family:"siyuan";
  color:#fff;
  max-width:900px;
  margin:0 auto;
  height:48px;
  margin-top:10px;
  position: absolute;
  top: 0;
  left: 25%;
  z-index: 999;
  .biaoti{
    font-family: siyuan;
    line-height:48px;
    display:inline-block;
    margin:0px;
    padding:0px;
    width:276px;
    width:276px;
    text-align:center;
    font-size:28px;
    font-weight: 600;
    letter-spacing: 3px;
  }
}


.fl{
  float:left
}
.fr{
  float:right
}

.info{
  position: absolute;
  top: 2.5vh;
  left: 0;
  width: 68%;
  display: flex;
  justify-content: space-between;
  height: 3vh;
  margin-left: 14vw;
  .date{
    //position: absolute;
    //left: 10%;
    //top: 3%;
    z-index: 999;
    letter-spacing: 1px;
    color: rgba(250,250,250,.8);
    font-family: ali;
  }
  .user-manage{
    display: flex;
    justify-content: space-between;
    .container{
      height: 3vh;
      width: 3vh;
      border-radius: 50%;
      border: 1px solid rgba(220, 223, 230, .7);
      background-color: rgba(220, 223, 230, .5);
      //height: 3vh;
      line-height: 3.6vh;
      color: rgba(250,250,250);
      font-size: 2vh;
      //margin-left:-1vw;
      margin-right: .3vw;
    }
    .options{
      display: flex;
      line-height: 3vh;
      color: white;
      font-size: 1.6vh;
      font-family: ali;
      .word{
        display: flex;
        letter-spacing: 1px;
        &:hover{
          cursor: pointer;
          .word{
            color: rgba(129, 133, 157);
          }
          .container{
            color: rgba(129, 133, 157);
            border: 1px solid rgba(129, 133, 157);
            background-color: rgba(250,250,250,.7);
          }

        }
      }
      .back{
        margin-left:2vw;
        height: 3vh;
        display: flex;
        align-items: center;
        &:hover{
          cursor: pointer;
          .word{
            color: rgba(129, 133, 157);
          }
          .container{
            color: rgba(129, 133, 157);
            border: 1px solid rgba(129, 133, 157);
            background-color: rgba(250,250,250,.7);
          }

        }
      }
    }
  }
}


</style>
